package com.cn.lp.export.server.entity;

import javax.persistence.*;

/**
 * 上传数据持久化对象
 */
@Entity
@Table(name = "export_sync_data",
    uniqueConstraints = {
        @UniqueConstraint(columnNames = {"taskId", "sort"})
    },
    indexes = {
        @Index(name = "taskId_index", columnList = "taskId")
    }
)
public class ExportSyncData {

    @Id
    @Column(nullable = false, unique = true)
    private long id;

    /** 任务Id */
    @Column
    private long taskId;

    /** 排序 */
    @Column
    private int sort;

    /** 数据 */
    @Column
    private byte[] data;

    public static ExportSyncData of(long id, long taskId, int sort, byte[] data) {
        ExportSyncData syncData = new ExportSyncData();
        syncData.id = id;
        syncData.taskId = taskId;
        syncData.sort = sort;
        syncData.data = data;
        return syncData;
    }

    public long getId() {
        return id;
    }

    public long getTaskId() {
        return taskId;
    }

    public int getSort() {
        return sort;
    }

    public byte[] getData() {
        return data;
    }
}
